<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
  <script src="./echarts.min.js"></script>
</head>
<body>
<div id="main" style="width: 800px;height:600px;"></div>
<script type="text/javascript">
  // 基于准备好的dom，初始化echarts实例
  var myChart = echarts.init(document.getElementById('main'));
 const dataSet = [
   [
     "新品类运营经营体",
     -0.001298773523565578,
     0.11732868724403853,
     0.11862746076760411,
     "净利润",
     "销售收入增长率"
   ],
   [
     "坚果品类运营经营体",
     -0.0002585042772681286,
     0.10219537626522737,
     0.1024538805424955,
     "净利润",
     "销售收入增长率"
   ],
   [
     "果干糖巧品类运营经营体",
     -0.0003698178242733188,
     -0.06039960415166886,
     0.06076942197594218,
     "净利润",
     "销售收入增长率"
   ],
   [
     "西式糕点品类运营经营体",
     -0.000745930015114758,
     -0.10188976420835448,
     0.10263569422346924,
     "净利润",
     "销售收入增长率"
   ],
   [
     "中式糕点品类运营经营体",
     -0.0008784275117347568,
     -0.1785660683319606,
     0.17944449584369535,
     "净利润",
     "销售收入增长率"
   ],
   [
     "饼膨食礼品类运营经营体",
     -0.0007218476682658012,
     -0.22346452327126193,
     0.22418637093952773,
     "净利润",
     "销售收入增长率"
   ],
   [
     "肉食品类运营经营体",
     -0.00033500513700388516,
     -0.000015889736706087942,
     0.0003508948737099731,
     "净利润",
     "销售收入增长率"
   ]
 ];
 let labelList = [];
 let xList = [];
 let yList = [];
 let sizeList = [];
 let series = [];
  var data = [
    [[1,3,1,'Australia',1990]],
    [[2,4.8,2,'Australia',2015]]
  ];
 dataSet.forEach((item,index)=>{
   labelList.push(item[0])
   let name = item[0]
   let x = item[1]*100
   let y = item[2]*100
   let size = item[3]*200
   let xLabel = item[4]
   let yLabel = item[5]
   data.push([[
     x,y,size,xLabel,name
   ]])
   xList.push(x)
   yList.push(y)
   sizeList.push(size)
   series.push({
     name: name,
     data: [[x, y, size,xLabel, name]],
     type: 'scatter',
     symbolSize:  function(){
       return size*5
     },
     label: {
       show: true,
       position: 'inside',
       color: '#333',
       formatter: function () {
         return item[0];
       },
     }
   })
 })

  console.log(data)
 let xMax=0,yMax=0;
  xList.forEach(item=>{
    item = item*100
    xMax=Math.abs(item)>xMax?Math.abs(item):xMax
  })
  yList.forEach(item=>{
    item = item*100
    yMax=Math.abs(item)>yMax?Math.abs(item):yMax
  })
  console.log(xMax,yMax)
  let x = Math.ceil(xMax*100)/100
  let y = Math.ceil(yMax*100)/100
  console.log(x,y)


  // 指定图表的配置项和数据
  var option = {

    title: {
    },
    tooltip: {

    },
    legend: {
      right: 10,
      data: labelList
    },
    xAxis: {
      splitLine: {
        lineStyle: {
          type: 'dashed'
        }
      },
      min: -10,
      max: 10,
    },
    yAxis: {
      splitLine: {
        lineStyle: {
          type: 'dashed'
        }
      },
      min: -10,
      max: 10,
      scale: true
    },
    series: series
  }

  // 使用刚指定的配置项和数据显示图表。
  myChart.setOption(option);
</script>
</body>
</html>
